<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/16
 * Time: 10:05
 */
// 媒体模型
Class mediaModel extends Model{
    /**
     * 获得单条数据
     * @param $condition 条件
     * @return mixed
     */
    public function getMediaByOne($condition,$field){
        return $this->where($condition)->field($field)->find();
    }

    /**
     * 获得多条数据
     * @param $condition 条件
     * @param $field 字段
     * @param $order 排序
     * @param $limit 数量
     * @return mixed
     */
    public function getMediaByMore($condition,$field,$order,$limit){
        return $this->where($condition)->field($field)->order($order)->limit($limit)->select();
    }

    /**
     * @param $data 数据
     * @return mixed|void
     */
    public function addMedia($data){
         if(empty($data)){
               return;
         }
         return $this->add($data);
    }

    /**
     * 更新数据
     */
    public function updata($condition,$data){
          return $this->where($condition)->save($data);
    }
}